home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk1 / color_twiddler / asrc1.d < prev    next >
Text File  |  1995-03-18  |  34KB  |  1,343 lines

  1.  
  2. ----------------------------
  3. Newsgroup comp.sources.amiga
  4. ----------------------------
  5.  
  6. Article 91 of 100, Dec 17 10:28.
  7. Subject: color loader/twiddler  (part 1 of 1)
  8. From: ain@j.cc.purdue.edu (Patrick White)
  9. Path: killer!codas!mtune!whuts!homxb!ihnp4!inuxc!iuvax!pur-ee!j.cc.purdue.edu!ain
  10. Organization: PUCC Land, USA
  11. Newsgroups: comp.sources.amiga
  12. Date: 17 Dec 87 16:28:25 GMT
  13.  
  14. Program Name:    colour
  15. Submitted By:    john13@garfield.mun.edu (John Russell)
  16. Summary:    This program allows loading/setting/saving/adjusting of
  17.         screen colors.  It can also be compiled to not allow
  18.         *adjusting* of colors (although setting, loading,
  19.         and saving still work) -- saves ~6K.
  20. Poster Boy:  Pat White  (ain@j.cc.purdue.edu)
  21. Untested  (meaning that I didn't try and compile it).
  22.  
  23. NOTES:
  24.    The built-in help for the un'FANCY' version tells about the "adjust"
  25. mode which is not available in it -- a simple code change that I didn't
  26. make.
  27.    The binary copies of these two programs were posted to
  28. comp.binaries.amiga.
  29.  
  30. -- Pat White   (co-moderator comp.sources/binaries.amiga)
  31. UUCP: k.cc.purdue.edu!ain  BITNET: PATWHITE@PURCCVM   PHONE: (317) 743-8421
  32. U.S.  Mail:  320 Brown St. apt. 406,    West Lafayette, IN 47906
  33.  
  34. ----------------------------------------
  35.  
  36.  
  37. #    This is a shell archive.
  38. #    Remove everything above and including the cut line.
  39. #    Then run the rest of the file through sh.
  40. #----cut here-----cut here-----cut here-----cut here----#
  41. #!/bin/sh
  42. # shar:    Shell Archiver
  43. #    Run the following text with /bin/sh to create:
  44. #    README
  45. #    colour.doc
  46. #    colorreq.c
  47. #    colour.c
  48. #    amber.col
  49. #    cyan.col
  50. #    gray.col
  51. #    green.col
  52. #    lace.col
  53. #    modem.col
  54. #    pastel.col
  55. #    red.col
  56. #    royal.col
  57. #    silver.col
  58. #    silver2.col
  59. #    wb.col
  60. # This archive created: Thu Dec 17 10:16:28 1987
  61. # By:    Patrick White (PUCC Land, USA)
  62. cat << \SHAR_EOF > README
  63. Please note that there are 2 versions of this program, a "large model" with
  64. all features implemented, and a "small model" that doesn't incorporate the
  65. colour requester. You can decide which one you want by making sure that the
  66. symbol FANCY is either defined or undefined during compilation.
  67.  
  68. If you don't want the colour requester in your version (ie you compile with
  69. FANCY undefined) you don't need to compile the file colorreq.c or link with
  70. colorreq.o.
  71.  
  72. John
  73. SHAR_EOF
  74. if test 462 -ne "`wc -c README`"
  75. then
  76. echo shar: error transmitting README '(should have been 462 characters)'
  77. fi
  78. cat << \SHAR_EOF > colour.doc
  79.  
  80. /*------------------------------------------------------------------------*/
  81.  
  82. Colour    - make a screen any colour you like, and load & save colour sets.
  83. ------
  84.  
  85. Copyright 1987, John Russell
  86.  
  87. 5 Alderdice Place
  88. St. John's, Newfoundland
  89. Canada     A1B 2P8
  90. (709) 726-7847
  91.  
  92. UseNet: john13@garfield.uucp
  93.     john13@garfield.mun.cdn
  94.  
  95. Freely redistributable.
  96.  
  97. /*------------------------------------------------------------------------*/
  98.  
  99.     This program has 4 uses:
  100.  
  101.     First, you can experiment with different colour combinations by actually
  102. specifying numeric parameters for Red, Green, and Blue. You can also do the
  103. same with numerous programs which use "slider gadgets", but I include the
  104. capability for completeness. Note there's also a slider-gadget option in
  105. this program which you can enable at compile time.
  106.  
  107.     Second, once you have found a colour combination you like, whether it's
  108. on your Workbench screen, or on the screen of some other program, you
  109. can save it to disk. The format of the saved file is very simple - for a
  110. screen with N colours, there are N lines with 3 integer values each, for
  111. Red, Green, and Blue which combine to any of the Amiga's 4096 possible
  112. colours.
  113.  
  114.     Third, you can instantly load this definition back in, and specify the
  115. screen whose colours you want to change. You can thus have special colours
  116. to use when running a word processor, terminal program, CLI session, etc.
  117. I personally have about 5 sets of colours I use depending on my mood, if
  118. my eyes are tired, if my monitor will be on for a long time and I want to
  119. save a few phosphor molecules, etc.
  120.  
  121.     Fourth, if you want to experiment with different colour combinations
  122. interactively, you can bring up a colour window requestor on a specified
  123. screen. This has the standard slider gadgets for adjusting colours and
  124. also features like copy, undo, and range. The range option is the only
  125. one that is not immediately obvious -- after selecting it, choose 2
  126. colours in the palette and all colours in between will be changed to
  127. a gradation somewhere between the two endpoints.
  128.  
  129. NB: This last option of the colour requestor may be omitted when the
  130. program is compiled (this saves about 5K), since many other programs
  131. are available that accomplish the same function. However I prefer to
  132. leave it enabled since the code doesn't have to stay in memory at all
  133. times as it does in most other similar utilities.
  134.  
  135. ------
  136. SYNTAX
  137. ------
  138.  
  139. To set one particular colour, on one particular screen -
  140. colour set <screen> index red green blue
  141.  
  142. To load a group of colours -
  143. colour load <screen> [from] <filename>
  144.  
  145. To save a group of colours -
  146. colour save <screen> [to] <filename>
  147.  
  148. To adjust colours with the mouse -
  149. colour adjust <screen>
  150.  
  151. If the screen has no title, you can specify "-null" in place of the title,
  152. in which case the first screen with no title is used. Only the first word
  153. of the title is considered, and case is not important. When loading a colour
  154. file, the current directory is searched first and then the S: directory.
  155. If the S: directory must be searched, the suffix ".col" is assumed to be
  156. present; thus the following two forms are equivalent :
  157.  
  158. colour load workbench from black-and-white
  159. colour load workbench from s:black-and-white.col
  160.  
  161. Examples -
  162.  
  163. colour set workbench 0 0 0 0      : sets Workbench background to black.
  164. colour load vt100 from modem.col  : set VT100 seperate screen colours.
  165. colour save -null to dpaint.col   : saves DPaint palette; screen has no title
  166. colour load workbench wb.col      : use the old Workbench colours
  167. colour save mandelbrot mand.col   : save a pretty-looking palette
  168. colour adjust workbench       : fairly powerful interactive control
  169.  
  170. ------------
  171. DISTRIBUTION
  172. ------------
  173.  
  174.     This program is freely redistributable; no fees beyond reasonable charge
  175. for media may be charged. 
  176.  
  177.     Source is included with this initial posting, along with an encoded
  178. version of the executable. The source may be informative if you are
  179. interested in how colours relate to the structure of the screen they affect.
  180. If you pass this program on, please keep at least this documentation with
  181. the executable. In the spirit of Canadian nationalism, I ask that you not 
  182. change the spelling of the excutable -- the "u" is supposed to be there.
  183.  
  184.     A portion of the source is derived from a public domain colour
  185. manipulation program. This section carries its own copyright notice and
  186. distribution conditions, which are present in the file colorreq.c if you
  187. have a copy of the source.
  188.  
  189.     No donations are solicited; however if you send me a disk with public
  190. domain software that you find useful (and possibly hasn't received wide
  191. distribution), I'll do the same from this end with some lesser-known programs
  192. that I use a lot.
  193.  
  194. John
  195. SHAR_EOF
  196. if test 4724 -ne "`wc -c colour.doc`"
  197. then
  198. echo shar: error transmitting colour.doc '(should have been 4724 characters)'
  199. fi
  200. cat << \SHAR_EOF > colorreq.c
  201.  
  202. /* I had nothing to do with this section other than removing a couple of */
  203. /* Latticisms. -- John */
  204.  
  205. /* This color requester was hacked out of a Mandelbrot program by
  206.    RJ Mical, Mike Ballantyne and R French.  I'm not sure which one of these
  207. deserves most of the credit for the colour requester but I suspect RJ Mical.
  208. I merely neatened up the code, fixed it so it wouldn't go glitchy with
  209. fast ram, got rid of 33 unnecessary gadgets, put in the numeric display of
  210. the rgb values of the current colour, fixed the display so it looks
  211. reasonable in less than 5 bit planes (it used to always try to show 32
  212. coloured squares, even if it only had two colours to work with), and made it
  213. as easy as possible to call from any program.  To access it from your
  214. program simply put in the statement  DoColorWindow(screen)  where screen is
  215. a pointer to your screen.  That's it.  This program (subroutine actually)
  216. may be freely distributed as long as this notice giving credit to the four
  217. contributing authors is left intact.  Pls address any correspondence
  218. regarding this program to :
  219.       Bruce Dawson
  220.       c/o CantorSoft.
  221.       407-1280 Haro St,
  222.       Vancouver
  223.       B.C.
  224.       V6E1E8
  225.  
  226.                 */
  227.  
  228.  
  229.  
  230.  
  231.  
  232. #include <clib/macros.h>
  233. #include <exec/types.h>
  234. #include <exec/tasks.h>
  235. #include <exec/devices.h>
  236. #include <devices/keymap.h>
  237. #include <graphics/copper.h>
  238. #include <graphics/display.h>
  239. #include <graphics/gels.h>
  240. #include <graphics/regions.h>
  241. #include <hardware/blit.h>
  242. #include <intuition/intuition.h>
  243. #include <intuition/intuitionbase.h>
  244.  
  245. /* Lattice sticks these two in a subdirectory. -- John */
  246.  
  247. #include <ctype.h>
  248. #include <stdio.h>
  249.  
  250. #include <libraries/dos.h>
  251.  
  252. /* === the definitions for the ColorWindow =============================== */
  253. #define KNOB_BODY      0x1111
  254.  
  255. #define WINDOW_WIDTH   208
  256. #define WINDOW_HEIGHT  106
  257.  
  258. #define WINDOW_LEFT   (320 - WINDOW_WIDTH)
  259. #define WINDOW_TOP   (200 - WINDOW_HEIGHT)
  260.  
  261. #define CHARACTER_WIDTH      8
  262. #define CHARACTER_HEIGHT   8
  263.  
  264. #define CURRENT_LEFT      6
  265. #define CURRENT_TOP     16
  266. #define CURRENT_RIGHT       (CURRENT_LEFT + 15)
  267. #define CURRENT_BOTTOM     (CURRENT_TOP + 29)
  268.  
  269. #define COLORS_TOP    55
  270.  
  271. #define PROP_LEFT      38
  272. #define PROP_TOP       14
  273. #define PROP_WIDTH    149
  274. #define PROP_HEIGHT    10
  275.  
  276. #define ACTIONS_LEFT  141
  277. #define ACTIONS_TOP    51
  278. #define ACTIONS_WIDTH    (CHARACTER_WIDTH * 6 + 4)
  279. #define ACTIONS_HEIGHT     9
  280.  
  281. /* GREEN and RED are out of order.  Do you wonder why?    Some day I'll
  282.  * tell you.  =RJ=
  283.  */
  284. #define COLOR_COPY          0
  285. #define COLOR_RANGE          1
  286. #define COLOR_OK          2
  287. #define COLOR_CANCEL          3
  288. #define COLOR_GREEN          4
  289. #define COLOR_RED          5
  290. #define COLOR_BLUE          6
  291. #define COLOR_GADGETS_COUNT   7
  292.  
  293.  
  294.  
  295. /***************************************************************************
  296.  *
  297.  * Color window template initialization and routines,
  298.  * for colorwindow and cyclewindow
  299.  *
  300.  * Throughout this file, the COLOR_RED and COLOR_GREEN gadgets are in the
  301.  * opposite order you would expect.
  302.  *
  303.  ****************************************************************************/
  304.  
  305. struct TextAttr safefont = {
  306.    (UBYTE *)"topaz.font",
  307.    TOPAZ_EIGHTY,
  308.    0,
  309.    0,
  310. };
  311.  
  312. struct IntuiText string =
  313. {
  314.    1, 0,         /* frontpen, backpen */
  315.    JAM2,         /* drawmode      */
  316.    0,0,          /* leftedge, topedge */
  317.    &safefont,         /* pointer to font   */
  318.    NULL,         /* pointer to text data */
  319.    NULL          /* next text */
  320. };
  321.  
  322.  
  323. SHORT actions_corners[] = {
  324.    -1, -1,
  325.    -1, ACTIONS_HEIGHT,
  326.    ACTIONS_WIDTH, ACTIONS_HEIGHT,
  327.    ACTIONS_WIDTH, -1,
  328.    -1, -1,
  329. };
  330.  
  331. struct Border actions_border = {
  332.    0, 0,
  333.    1, 0,
  334.    JAM1,
  335.    5,
  336.    actions_corners,
  337.    NULL,
  338. };
  339.  
  340. struct IntuiText actions_text[4] = {
  341.    { /* "COPY" */
  342.       1, 0,
  343.       JAM2,
  344.       2 + CHARACTER_WIDTH, 1,
  345.       &safefont,
  346.       (UBYTE *)"COPY",
  347.       NULL,
  348.    },
  349.    { /* "RANGE" */
  350.       1, 0,
  351.       JAM2,
  352.       2 + (CHARACTER_WIDTH >> 1), 1,
  353.       &safefont,
  354.       (UBYTE *)"RANGE",
  355.       NULL,
  356.    },
  357.    { /* "OK" */
  358.       1, 0,
  359.       JAM2,
  360.       2 + (CHARACTER_WIDTH << 1), 1,
  361.       &safefont,
  362.       (UBYTE *)"OK",
  363.       NULL,
  364.    },
  365.    { /* "CANCEL" */
  366.       1, 0,
  367.       JAM2,
  368.       2, 1,
  369.       &safefont,
  370.       (UBYTE *)"CANCEL",
  371.       NULL,
  372.    },
  373. };
  374.  
  375.  
  376. /* ======================================================================== */
  377. /* ======================================================================== */
  378. /* ======================================================================== */
  379. /* RJM anchor */
  380. struct Image   ColorPropsImages[3];
  381. struct Image   ColorImage =
  382.    {
  383.    CURRENT_LEFT, COLORS_TOP,           /* left edge, top edge */
  384.    15, 10, 0,                   /* width, height, depth */
  385.    NULL,                   /* image data */
  386.    0,                       /* planepick */
  387.    0,                       /* planeonoff - set later */
  388.    NULL                    /* NextImage */
  389.    };
  390.  
  391. struct PropInfo ColorPropsInfos[3] = {
  392.    { /* COLOR_GREEN */
  393.       AUTOKNOB | FREEHORIZ,
  394.       0,
  395.       0,
  396.       KNOB_BODY,
  397.       0,
  398.       0, 0, 0, 0, 0, 0,
  399.    },
  400.    { /* COLOR_RED */
  401.       AUTOKNOB | FREEHORIZ,
  402.       0,
  403.       0,
  404.       KNOB_BODY,
  405.       0,
  406.       0, 0, 0, 0, 0, 0,
  407.    },
  408.    { /* COLOR_BLUE */
  409.       AUTOKNOB | FREEHORIZ,
  410.       0,
  411.       0,
  412.       KNOB_BODY,
  413.       0,
  414.       0, 0, 0, 0, 0, 0,
  415.    },
  416. };
  417.  
  418. struct Gadget gadglist[COLOR_GADGETS_COUNT] = {
  419.    { /* COLOR_COPY */
  420.       NULL,
  421.       ACTIONS_LEFT,
  422.       ACTIONS_TOP + (0 * (ACTIONS_HEIGHT + 3)),
  423.       ACTIONS_WIDTH,
  424.       ACTIONS_HEIGHT,
  425.       GADGHCOMP,
  426.       RELVERIFY,
  427.       BOOLGADGET,
  428.       (APTR)&actions_border,
  429.       NULL,
  430.       &actions_text[0],
  431.       NULL,
  432.       NULL,
  433.       COLOR_COPY,
  434.       NULL,
  435.    },
  436.    { /* COLOR_RANGE */
  437.       &gadglist[COLOR_COPY],
  438.       ACTIONS_LEFT,
  439.       ACTIONS_TOP + (01 * (ACTIONS_HEIGHT + 3)),
  440.       ACTIONS_WIDTH,
  441.       ACTIONS_HEIGHT,
  442.       GADGHCOMP,
  443.       RELVERIFY,
  444.       BOOLGADGET,
  445.       (APTR)&actions_border,
  446.       NULL,
  447.       &actions_text[01],
  448.       NULL,
  449.       NULL,
  450.       COLOR_RANGE,
  451.       NULL,
  452.    },
  453.    { /* COLOR_OK */
  454.       &gadglist[COLOR_RANGE],
  455.       ACTIONS_LEFT,
  456.       ACTIONS_TOP + (02 * (ACTIONS_HEIGHT + 3)),
  457.       ACTIONS_WIDTH,
  458.       ACTIONS_HEIGHT,
  459.       GADGHCOMP,
  460.       RELVERIFY,
  461.       BOOLGADGET,
  462.       (APTR)&actions_border,
  463.       NULL,
  464.       &actions_text[02],
  465.       NULL,
  466.       NULL,
  467.       COLOR_OK,
  468.       NULL,
  469.    },
  470.    { /* COLOR_CANCEL */
  471.       &gadglist[COLOR_OK],
  472.       ACTIONS_LEFT,
  473.       ACTIONS_TOP + (03 * (ACTIONS_HEIGHT + 3)),
  474.       ACTIONS_WIDTH,
  475.       ACTIONS_HEIGHT,
  476.       GADGHCOMP,
  477.       RELVERIFY,
  478.       BOOLGADGET,
  479.       (APTR)&actions_border,
  480.       NULL,
  481.       &actions_text[03],
  482.       NULL,
  483.       NULL,
  484.       COLOR_CANCEL,
  485.       NULL,
  486.    },
  487.    { /* COLOR_GREEN */
  488.       &gadglist[COLOR_CANCEL],
  489.       PROP_LEFT,
  490.       PROP_TOP + (01 * (PROP_HEIGHT + 1)),
  491.       PROP_WIDTH,
  492.       PROP_HEIGHT,
  493.       GADGHCOMP | GADGIMAGE,
  494.       FOLLOWMOUSE,
  495.       PROPGADGET,
  496.       (APTR)&ColorPropsImages[01],
  497.       NULL,
  498.       NULL,
  499.       NULL,
  500.       (APTR)&ColorPropsInfos[01],
  501.       COLOR_GREEN,
  502.       NULL,
  503.    },
  504.    { /* COLOR_RED */
  505.       &gadglist[COLOR_GREEN],
  506.       PROP_LEFT,
  507.       PROP_TOP + (00 * (PROP_HEIGHT + 1)),
  508.       PROP_WIDTH,
  509.       PROP_HEIGHT,
  510.       GADGHCOMP | GADGIMAGE,
  511.       FOLLOWMOUSE,
  512.       PROPGADGET,
  513.       (APTR)&ColorPropsImages[00],
  514.       NULL,
  515.       NULL,
  516.       NULL,
  517.       (APTR)&ColorPropsInfos[00],
  518.       COLOR_RED,
  519.       NULL,
  520.    },
  521.    { /* COLOR_BLUE */
  522.       &gadglist[COLOR_RED],
  523.       PROP_LEFT,
  524.       PROP_TOP + (02 * (PROP_HEIGHT + 1)),
  525.       PROP_WIDTH,
  526.       PROP_HEIGHT,
  527.       GADGHCOMP | GADGIMAGE,
  528.       FOLLOWMOUSE,
  529.       PROPGADGET,
  530.       (APTR)&ColorPropsImages[02],
  531.       NULL,
  532.       NULL,
  533.       NULL,
  534.       (APTR)&ColorPropsInfos[02],
  535.       COLOR_BLUE,
  536.       NULL,
  537.    },
  538. };
  539.  
  540.  
  541. /*----------------------*/
  542. /* Graphics definitions */
  543.  
  544. struct     RastPort    *rstport;
  545. struct     ViewPort    *vp;
  546.  
  547. struct     Window      *ColorWindow;
  548.  
  549. /*****************************************************************************
  550.  *
  551.  * Color initialization and routines
  552.  *
  553.  ****************************************************************************/
  554.  
  555. #define COPYCOLOR    1
  556. #define RANGE_FIRST    2
  557. #define RANGE_SECOND    3
  558.  
  559. USHORT     ColorMode;
  560.  
  561. USHORT     SavePalette[32];
  562.  
  563. #define COLOR_IDCMP_FLAGS (GADGETDOWN | GADGETUP | MOUSEBUTTONS \
  564.       | MENUPICK | MOUSEMOVE | ACTIVEWINDOW | INACTIVEWINDOW)
  565.  
  566. struct NewWindow ColorNewWindow =
  567.    {
  568.    WINDOW_LEFT, WINDOW_TOP,
  569.    WINDOW_WIDTH, WINDOW_HEIGHT,
  570.    -1, -1,
  571.    COLOR_IDCMP_FLAGS,
  572.    WINDOWDRAG | SMART_REFRESH | NOCAREREFRESH | ACTIVATE,
  573.    NULL,             /* struct Gadget *FirstGadget; */
  574.    NULL,             /* struct Image *CheckMark; */
  575.    "Modify Colours.",  /* the title text for this window */
  576.    NULL,             /* struct Screen *Screen; */
  577.    NULL,             /* struct BitMap *BitMap; */
  578.    0, 0,
  579.    0, 0,
  580.    CUSTOMSCREEN,         /* USHORT Type; */
  581.    };
  582.  
  583. USHORT     RangeFirst;   /* the first selection of the range-color pair */
  584.  
  585. /* ======================================================================== */
  586. /* ======================================================================== */
  587.  
  588. BOOL OpenColorWindow(screen, colours)
  589. struct Screen *screen;
  590. short           colours;
  591. {
  592.    REGISTER LONG   i;
  593.  
  594.    ColorNewWindow.Screen = screen;
  595.    ColorNewWindow.FirstGadget=&gadglist[COLOR_GADGETS_COUNT - 1];
  596.    ColorMode = NULL;
  597.    if ( ! (ColorWindow = (struct Window *)OpenWindow(&ColorNewWindow)))
  598.       return(FALSE);
  599.    rstport = ColorWindow->RPort;
  600.    SetAPen(rstport, 1);
  601.    SetColorProps();
  602.    for (i = 0; i < 32; i++)
  603.       SavePalette[i] = GetRGB4(vp->ColorMap, i);
  604.    DrawColorWindow(colours);
  605.    return(TRUE);
  606. }
  607.  
  608. VOID CloseColorWindow(accept)
  609. BOOL accept;
  610. {
  611.    if ( NOT ColorWindow)
  612.       return;
  613.    CloseWindow(ColorWindow);
  614.    ColorWindow = NULL;
  615.    if (NOT accept)
  616.       LoadRGB4(vp, &SavePalette[0], 32L);
  617. }
  618.  
  619. VOID ColorRange(first, last)
  620. SHORT first, last;
  621. {
  622.    REGISTER SHORT   i;
  623.    LONG      whole, redfraction, greenfraction, bluefraction;
  624.    REGISTER USHORT   rgb;
  625.    SHORT      firstred, firstgreen, firstblue;
  626.    SHORT      lastred, lastgreen, lastblue;
  627.    SHORT      workred, workgreen, workblue;
  628.  
  629.    if (first > last) {
  630.       i = first;
  631.       first = last;
  632.       last = i;
  633.    }
  634.    /* I need to see a spread of at least two, where there's at least one
  635.     * spot between the endpoints, else there's no work to do so I
  636.     * might as well just return now.
  637.     */
  638.    if (first >= last - 1)
  639.       return;
  640.  
  641.    rgb = GetRGB4(vp->ColorMap, (LONG)first);
  642.    firstred = (rgb >> 8) & 0xF;
  643.    firstgreen = (rgb >> 4) & 0xF;
  644.    firstblue = (rgb >> 0) & 0xF;
  645.  
  646.    rgb = GetRGB4(vp->ColorMap, (LONG)last);
  647.    lastred = (rgb >> 8) & 0xF;
  648.    lastgreen = (rgb >> 4) & 0xF;
  649.    lastblue = (rgb >> 0) & 0xF;
  650.  
  651.    whole = ((LONG) (lastred - firstred)) << 16;
  652.    redfraction = whole / (last - first);
  653.    whole = ((LONG)(lastgreen - firstgreen)) << 16;
  654.    greenfraction = whole / (last - first);
  655.    whole = ((LONG)(lastblue - firstblue)) << 16;
  656.    bluefraction = whole / (last - first);
  657.  
  658.    for (i = first + 1; i < last; i++)
  659.       {
  660.       lastred = (redfraction * (i - first) + 0x8000) >> 16;
  661.       workred = firstred + lastred;
  662.       lastgreen = (greenfraction * (i - first) + 0x8000) >> 16;
  663.       workgreen = firstgreen + lastgreen;
  664.       lastblue = (bluefraction * (i - first) + 0x8000) >> 16;
  665.       workblue = firstblue + lastblue;
  666.       SetRGB4(vp, (LONG) i,(LONG)workred,(LONG)workgreen,(LONG)workblue);
  667.       }
  668. }
  669.  
  670. BOOL colorchosen(pen)
  671. short pen;
  672. {
  673.    REGISTER USHORT   rgb;
  674.  
  675.    complementbox(rstport, rstport->FgPen);
  676.    complementbox(rstport, pen);
  677.  
  678.    if (ColorMode == COPYCOLOR)
  679.       {
  680.       rgb = GetRGB4(vp->ColorMap, (LONG)rstport->FgPen);
  681.       SetRGB4(vp,  pen, (rgb >> 8), (rgb >> 4), rgb );
  682.       ColorMode = NULL;
  683.       }
  684.    if (ColorMode == RANGE_FIRST)
  685.       {
  686.       ColorMode = RANGE_SECOND;
  687.       RangeFirst = pen;
  688.       }
  689.    else if (ColorMode == RANGE_SECOND)
  690.       {
  691.       ColorMode = NULL;
  692.       ColorRange(RangeFirst, pen);
  693.       }
  694.  
  695.    SetAPen(rstport, (LONG)pen);
  696.    rgb = GetRGB4(vp->ColorMap, (LONG)pen);
  697.    ColorRectFill((LONG)pen);
  698.  
  699.    SetColorProps();
  700. }
  701.  
  702.  
  703.  
  704. BOOL GadgetGotten(gadgetnum)
  705. short gadgetnum;
  706. {
  707.    switch (gadgetnum)
  708.       {
  709.       case COLOR_OK:
  710.      CloseColorWindow(TRUE);
  711.      return(FALSE);
  712.       case COLOR_CANCEL:
  713.      CloseColorWindow(FALSE);
  714.      return(FALSE);
  715.       case COLOR_COPY:
  716.      ColorMode = COPYCOLOR;
  717.      break;
  718.       case COLOR_RANGE:
  719.      ColorMode = RANGE_FIRST;
  720.      break;
  721.       }
  722.    return(TRUE);
  723. }
  724.  
  725.  
  726. ModifyColors()
  727. {
  728.    USHORT      pen;
  729.    REGISTER USHORT   newred, newgreen, newblue;
  730.  
  731.    pen = rstport->FgPen;
  732.    newred = ((struct PropInfo *)
  733.           gadglist[COLOR_RED].SpecialInfo)->HorizPot >> 12;
  734.    newgreen = ((struct PropInfo *)
  735.           gadglist[COLOR_GREEN].SpecialInfo)->HorizPot >> 12;
  736.    newblue = ((struct PropInfo *)
  737.           gadglist[COLOR_BLUE].SpecialInfo)->HorizPot >> 12;
  738.    SetRGB4(vp, (LONG)pen, (LONG)newred, (LONG)newgreen, (LONG)newblue);
  739.  
  740.    printcolors(newred, newgreen, newblue);
  741. }
  742.  
  743.  
  744.  
  745. printcolors(red, green, blue)
  746. USHORT     red, green, blue;
  747. {
  748.    char *buffer = "  ";
  749.  
  750.    sprintf(buffer, "%2d", red);
  751.    printtext(buffer, PROP_WIDTH + PROP_LEFT+2, CURRENT_TOP);
  752.  
  753.    sprintf(buffer, "%2d", green);
  754.    printtext(buffer, PROP_WIDTH + PROP_LEFT+2, CURRENT_TOP+(PROP_HEIGHT+1));
  755.  
  756.    sprintf(buffer, "%2d", blue);
  757.    printtext(buffer, PROP_WIDTH + PROP_LEFT+2, CURRENT_TOP
  758.                          + (PROP_HEIGHT+1) * 2);
  759. }
  760.  
  761.  
  762.  
  763. DrawColorWindow(colours)
  764. {
  765.    REGISTER SHORT i;
  766.  
  767.    ColorRectFill((LONG)rstport->FgPen);
  768.    DrawBox(rstport, CURRENT_LEFT-2,CURRENT_TOP-2,CURRENT_RIGHT+2,CURRENT_BOTTOM+2);
  769.    DrawBox(rstport, CURRENT_LEFT-2, COLORS_TOP-2, CURRENT_LEFT+(8 * 15)+1,
  770.                     COLORS_TOP + (4 * 10) + 1);
  771.    printtext("R", CURRENT_RIGHT + 6, CURRENT_TOP);
  772.    printtext("G", CURRENT_RIGHT + 6, CURRENT_TOP + PROP_HEIGHT+1);
  773.    printtext("B", CURRENT_RIGHT + 6, CURRENT_TOP + (PROP_HEIGHT+1)* 2);
  774.  
  775.    for (i = 0; i < colours; i++)
  776.       {
  777.       ColorImage.PlaneOnOff = i;
  778.       DrawImage(rstport, &ColorImage, (i % 8) * 15, (i / 8) * 10);
  779.       }
  780.    complementbox(rstport, 1);        /* starting colour is colour 1 */
  781. }
  782.  
  783.  
  784.  
  785. SetColorProps()
  786. {
  787.    USHORT      rgb;
  788.    REGISTER USHORT   red, green, blue;
  789.    SHORT      greenpos, redpos, bluepos;
  790.  
  791.    redpos = RemoveGadget(ColorWindow, &gadglist[COLOR_RED]);
  792.    greenpos = RemoveGadget(ColorWindow, &gadglist[COLOR_GREEN]);
  793.    bluepos = RemoveGadget(ColorWindow, &gadglist[COLOR_BLUE]);
  794.  
  795.    rgb = GetRGB4(vp->ColorMap, (LONG)rstport->FgPen);
  796.    red = (rgb >> 8) & 0xF;
  797.    green = (rgb >> 4) & 0xF;
  798.    blue = (rgb >> 0) & 0xF;
  799.  
  800.    ((struct PropInfo *)gadglist[COLOR_RED].SpecialInfo)->HorizPot
  801.            = (red << 12) | (red << 8) | (red << 4) | red;
  802.    ((struct PropInfo *)gadglist[COLOR_GREEN].SpecialInfo)->HorizPot
  803.            = (green << 12) | (green << 8) | (green << 4) | green;
  804.    ((struct PropInfo *)gadglist[COLOR_BLUE].SpecialInfo)->HorizPot
  805.            = (blue << 12) | (blue << 8) | (blue << 4) | blue;
  806.  
  807.    AddGadget(ColorWindow,&gadglist[COLOR_BLUE], (LONG)bluepos);
  808.    AddGadget(ColorWindow,&gadglist[COLOR_GREEN],(LONG)greenpos);
  809.    AddGadget(ColorWindow,&gadglist[COLOR_RED], (LONG)redpos);
  810.  
  811.    RefreshGadgets(&gadglist[COLOR_GADGETS_COUNT-1],ColorWindow);
  812.  
  813.    printcolors(red, green, blue);
  814. }
  815.  
  816.  
  817. ColorRectFill( pen)
  818. LONG pen;
  819. {
  820.    SetAPen(rstport, pen);
  821.    SetDrMd(rstport, JAM2);
  822.    WaitBOVP(vp);
  823.    RectFill(rstport, CURRENT_LEFT, CURRENT_TOP, CURRENT_RIGHT, CURRENT_BOTTOM);
  824. }
  825.  
  826. VOID DoColorWindow(screen)
  827. struct Screen *screen;
  828. {
  829.    BOOL        GadgetGotten(), OpenColorWindow();
  830.    REGISTER struct IntuiMessage   *message;
  831.    REGISTER ULONG          class;
  832.    REGISTER struct Gadget      *gadget;
  833.    USHORT   bitplanes, colours, code;
  834.    short    number, x, y;
  835.  
  836.  
  837.    vp = &screen->ViewPort;
  838.    bitplanes = screen->BitMap.Depth;
  839.    for (colours = 1; bitplanes; bitplanes--)
  840.       colours *= 2;
  841.    if (colours > 32)
  842.       colours = 32;
  843.  
  844.    if (NOT OpenColorWindow(screen, colours))
  845.       return;
  846.    FOREVER {
  847.       Wait((1L << ColorWindow->UserPort->mp_SigBit));
  848.       while (message = (struct IntuiMessage *)GetMsg(ColorWindow->UserPort)) {
  849.      class = message->Class;
  850.      code = message->Code;
  851.      x = message->MouseX;
  852.      y = message->MouseY;
  853.      if (class != MOUSEBUTTONS)
  854.         gadget = (struct Gadget *)(message->IAddress);
  855.      ReplyMsg(message);
  856.      switch (class) {
  857.         case GADGETDOWN:
  858.         case GADGETUP:
  859.            if ( NOT GadgetGotten(gadget->GadgetID))
  860.           return;
  861.            break;
  862.         case MOUSEBUTTONS:
  863.            if ( x >= CURRENT_LEFT && x < CURRENT_LEFT + 8 * 15)
  864.           if (y >= COLORS_TOP && y < COLORS_TOP + 4 * 10)
  865.              {
  866.              number = (x-CURRENT_LEFT)/15 + ((y-COLORS_TOP)/10)*8;
  867.              if (number < colours && code == SELECTDOWN)
  868.             colorchosen(number);
  869.              }
  870.            break;
  871.         case MOUSEMOVE:
  872.            ModifyColors();
  873.            break;
  874.         default:
  875.            break;
  876.      }
  877.       }
  878.    }
  879. }
  880.  
  881.  
  882.  
  883. DrawBox(rp, x1, y1, x2, y2)
  884. struct RastPort *rp;
  885. short     x1, y1, x2, y2;
  886. /* draws a box without overlapping the edges (in case of complement mode) */
  887. {
  888.    Move(rp, x1, y1 + SIGN(y2 - y1));
  889.    Draw(rp, x1, y2);
  890.    Move(rp, x1 + SIGN(x2 - x1), y2);
  891.    Draw(rp, x2, y2);
  892.    Move(rp, x2, y2 - SIGN(y2 - y1));
  893.    Draw(rp, x2, y1);
  894.    Move(rp, x2 - SIGN(x2 - x1), y1);
  895.    Draw(rp, x1, y1);
  896. }
  897.  
  898.  
  899.  
  900. complementbox(rp, colours)
  901. short colours;
  902. {
  903. short x, y;
  904.  
  905.    x = CURRENT_LEFT + (colours % 8) * 15;
  906.    y = COLORS_TOP + (colours / 8) * 10;
  907.  
  908.    SetDrMd(rp, COMPLEMENT);
  909.    DrawBox(rp, x, y, x + 14, y + 9);
  910.    SetDrMd(rp, JAM1);
  911. }
  912.  
  913.  
  914.  
  915. printtext(text, x, y)
  916. char     *text;
  917. short     x, y;
  918. {
  919.    string.IText = text;
  920.    PrintIText(rstport, &string, x, y);
  921. }
  922. SHAR_EOF
  923. if test 17372 -ne "`wc -c colorreq.c`"
  924. then
  925. echo shar: error transmitting colorreq.c '(should have been 17372 characters)'
  926. fi
  927. cat << \SHAR_EOF > colour.c
  928. /*
  929.  *  Colour.c - a program for manipulating the colours of screens.
  930.  *
  931.  *  Written because I like one set of colours in a CLI and another in
  932.  *  my terminal window, and can't always afford the memory for another
  933.  *  screen. Plus, I like a more direct way of changing colours than
  934.  *  twiddling a bunch of slider gadgets (although that way has its uses
  935.  *  too, so I include the capability). Lastly, Americans don't know
  936.  *  how to spell "colour" :-).
  937.  *
  938.  *  Features include:
  939.  *    - save all colours from a given screen
  940.  *    - load a set of colours into a given screen
  941.  *    - set a particular colour register in a given screen
  942.  *    - adjust screen colours interactively (OPTIONAL)
  943.  *
  944.  *  Copyright 1987, John Russell
  945.  *
  946.  *  5 Alderdice Place
  947.  *  St. John's, Newfoundland
  948.  *  Canada   A1B 2P8
  949.  *  (709) 726-7847
  950.  *
  951.  *  Freely redistributable.
  952.  */
  953.  
  954. /* Manx users compile with "+l" just in case */
  955.  
  956. /* These includes might not be enough, I use precompiled includes. */
  957. /* anything to do with screens & viewports may be required */
  958.  
  959. #include <intuition/intuition.h>
  960. #include <intuition/intuitionbase.h>
  961. #include <stdio.h>
  962. #include "ctype.h"
  963.  
  964. #define LOAD 1
  965. #define SAVE 2
  966. #define SET 3
  967. #define ADJUST 4
  968.  
  969. /* if "fancy" is defined, you have the option to adjust on-the-fly */
  970.  
  971. #define FANCY 1
  972.  
  973. /* debug = "puts" to enable tracing, leave blank to disable */
  974.  
  975. #define debug(x)
  976.  
  977. struct IntuitionBase *IntuitionBase=NULL;
  978. struct GfxBase *GfxBase=NULL;
  979.  
  980. char *usage = "\n\
  981. Bad syntax.\n\n\
  982. Usage 1: colour load   <screen | \"-null\"> [from] <filename>.\n\
  983. Usage 2: colour save   <screen | \"-null\"> [to] <filename>.\n\
  984. Usage 3: colour set    <screen | \"-null\"> index R G B.\n\
  985. Usage 4: colour adjust <screen | \"-null\">.\n\n\
  986. Note  -  Specify screen by first word of title (case doesn't matter).\n\
  987. Note  -  Load file is searched for as \"file\" and \"s:file.col\".\n";
  988.  
  989. main(argc,argv)
  990. int argc;
  991. char *argv[];
  992. {
  993.     struct Screen *screen;    /* which screen to consider */
  994.     struct ViewPort *vp;    /* controlling viewport for screen */
  995.     FILE *fp;            /* for loading & saving */
  996.     short good_args = 0;    /* right # arguments for syntax? */
  997.     short mode = 0;        /* what type of command is it? */
  998.     int r,g,b;
  999.     int i,n,fname,depth;    /* depth == number of colours in screen */
  1000.     UWORD colour;        /* I only remember these typedefs */
  1001.     struct ColorMap *map;      /* when reading includes :-) */
  1002.     char name[80];
  1003.  
  1004.     /* check for valid arguments and commands */
  1005.  
  1006.     if (argc < 3)    /* always need at least 3 */
  1007.     {
  1008.     puts(usage);
  1009.     exit(0);
  1010.     }
  1011.     else if (!compare(argv[1],"load"))
  1012.     {
  1013.     debug("Asked to load a colour set.");
  1014.     mode = LOAD;
  1015.     if (argc == 4 || (!compare(argv[3],"from") && argc == 5))
  1016.         good_args = 1;
  1017.     }
  1018.     else if (!compare(argv[1],"save"))
  1019.     {
  1020.     debug("Asked to save a colour set.");
  1021.     mode = SAVE;
  1022.     if (argc == 4 || (!compare(argv[3],"to") && argc == 5))
  1023.         good_args = 1;
  1024.     }
  1025.     else if (!compare(argv[1],"set"))
  1026.     {
  1027.     debug("Asked to set a single colour.");
  1028.     mode = SET;
  1029.     if (argc == 7) good_args = 1;
  1030.     }
  1031.  
  1032. #ifdef FANCY
  1033.     else if (!compare(argv[1],"adjust"))
  1034.     {
  1035.     debug("Asked to adjust screen colours.");
  1036.     mode = ADJUST;
  1037.     if (argc == 3) good_args = 1;
  1038.     }
  1039. #endif
  1040.  
  1041.     fname = argc - 1;    /* argv[fname] = file for load & save */
  1042.  
  1043.     if (!good_args) {
  1044.     puts(usage);
  1045.     exit(0);
  1046.     }
  1047.  
  1048.     debug("Arguments are legal.");
  1049.  
  1050.     if (! (IntuitionBase = (struct IntuitionBase *)
  1051.         OpenLibrary("intuition.library",33L)))
  1052.     {
  1053.     puts("Please use Kickstart/Workbench V1.2 for latest Intuition.");
  1054.     exit(0);
  1055.     }
  1056.  
  1057.     if (! (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",33L)))
  1058.     {
  1059.     puts("Please use Kickstart/Workbench V1.2 for latest Graphics.");
  1060.     exit(0);
  1061.     }
  1062.  
  1063.     screen = IntuitionBase->FirstScreen;
  1064.  
  1065. /* the target screen is found when the first word of the title matches the
  1066.    2nd argument specified, OR if the 2nd argument is -null, the first
  1067.    screen with NO title is matched (eg the DPaint screen) */
  1068.  
  1069.     LockIBase(NULL);    /* prevent window list from changing while in loop */
  1070.  
  1071.     while (screen)    /* do all screens */
  1072.     {
  1073.         if (!compare(argv[2],screen->Title) ||
  1074.            ((screen->Title == NULL) && (!compare(argv[2],"-null"))))
  1075.         {
  1076.         UnlockIBase(NULL);
  1077.  
  1078.         debug("Found the indicated screen.");
  1079.  
  1080.         vp = &screen->ViewPort;     /* don't like 'em much myself */
  1081.         map = vp->ColorMap;
  1082.         depth = 1 << screen->BitMap.Depth;   /* no easier way? */
  1083.  
  1084.         switch (mode)
  1085.         {
  1086.  
  1087.             case SET:
  1088.  
  1089.             i = atoi(argv[3]);  /* colour index */
  1090.             r = atoi(argv[4]);  /* RGB values */
  1091.             g = atoi(argv[5]);
  1092.             b = atoi(argv[6]);
  1093.  
  1094.             if (i < depth)
  1095.             {
  1096.                 SetRGB4(vp,i,r,g,b);
  1097.                 debug("Set single colour.");
  1098.             }
  1099.             else
  1100.                 puts("Illegal colour index for this screen.");
  1101.  
  1102.             break;
  1103.  
  1104.             case LOAD:    /* (LA Law is on in the background) */
  1105.  
  1106.             /* search current directory and S: for file */
  1107.  
  1108.             /* look for for file as "file" and "s:file.col" */
  1109.  
  1110.  
  1111.             if (!(fp = fopen(argv[fname],"r")))
  1112.             {
  1113.                 /* Boy do I hate C string functions! */
  1114.  
  1115.                 strcpy(name,"s:");
  1116.                 strcat(name,argv[fname]);
  1117.                 strcat(name,".col");
  1118.  
  1119.                 debug("Searching for file in S: directory.");
  1120.                 fp = fopen(name,"r");
  1121.             }
  1122.  
  1123.             if (!fp)
  1124.             {
  1125.                 puts("Unable to open load file!");
  1126.                 goto QUIT;
  1127.             }
  1128.  
  1129.             debug("Opened file successfully.");
  1130.  
  1131.             /* This is an *ugly* loop condition! */
  1132.  
  1133.             for (i=0;
  1134.                  (i < depth)
  1135.                 &&
  1136.                  (fscanf(fp,"%d %d %d\n",&r,&g,&b)==3);
  1137.                  i++)
  1138.             {
  1139.                 SetRGB4(vp,i,r,g,b);
  1140.                 debug("Set a colour.");
  1141.             }
  1142.  
  1143.             fclose(fp);
  1144.             break;
  1145.  
  1146.             case SAVE:
  1147.  
  1148.             fp = fopen(argv[fname],"w");
  1149.  
  1150.             if (!fp) {
  1151.                 puts("Unable to open save file!");
  1152.                 goto QUIT;
  1153.             }
  1154.  
  1155.             for (i=0; i < depth; i++)
  1156.             {
  1157.                 colour = GetRGB4(map,i);
  1158.  
  1159.                 /* each colour component encoded by 4 bits */
  1160.  
  1161.                 r = (colour & 0xf00) >> 8;
  1162.                 g = (colour & 0x0f0) >> 4;
  1163.                 b = (colour & 0x00f);
  1164.  
  1165.                 fprintf(fp,"%d %d %d\n",r,g,b);
  1166.                 debug("Saved a colour.");
  1167.             }
  1168.  
  1169.             fclose(fp);
  1170.  
  1171.             break;
  1172.  
  1173. #ifdef FANCY
  1174.             case ADJUST:
  1175.             ScreenToFront(screen);
  1176.             DoColorWindow(screen);    /* I can't take credit for */
  1177.             break;            /* this section */
  1178. #endif
  1179.  
  1180.             default:
  1181.  
  1182.             debug("Illegal instruction mode.");
  1183.             break;
  1184.         }
  1185.  
  1186.         goto QUIT;    /* only match 1 screen */
  1187.  
  1188.         }
  1189.  
  1190.         screen = screen->NextScreen;
  1191.  
  1192.     }
  1193.  
  1194.     UnlockIBase(NULL);    /* didn't find the screen at all */
  1195.     debug("Didn't find indicated screen.");
  1196.  
  1197. QUIT:
  1198.     CloseLibrary(IntuitionBase);
  1199.     CloseLibrary(GfxBase);
  1200. }
  1201.  
  1202. /* case-insensitive string comparison, with \0 and space as end conditions */
  1203.  
  1204. compare(string1,string2)
  1205. char *string1,*string2;
  1206. {
  1207.     while ((*string1 != '\0') && (*string1 != ' '))
  1208.     {
  1209.     if (toupper(*(string1++)) != toupper(*(string2++)))
  1210.         return(1);
  1211.     }
  1212.     return(0);    /* return weird values like strcmp() */
  1213. }
  1214.  
  1215. SHAR_EOF
  1216. if test 6787 -ne "`wc -c colour.c`"
  1217. then
  1218. echo shar: error transmitting colour.c '(should have been 6787 characters)'
  1219. fi
  1220. cat << \SHAR_EOF > amber.col
  1221. 0 0 1
  1222. 13 13 2
  1223. 0 0 8
  1224. 15 15 15
  1225. SHAR_EOF
  1226. if test 29 -ne "`wc -c amber.col`"
  1227. then
  1228. echo shar: error transmitting amber.col '(should have been 29 characters)'
  1229. fi
  1230. cat << \SHAR_EOF > cyan.col
  1231. 0 0 0
  1232. 0 15 15
  1233. 0 0 7
  1234. 15 15 0
  1235. SHAR_EOF
  1236. if test 28 -ne "`wc -c cyan.col`"
  1237. then
  1238. echo shar: error transmitting cyan.col '(should have been 28 characters)'
  1239. fi
  1240. cat << \SHAR_EOF > gray.col
  1241. 3 3 3
  1242. 15 15 15
  1243. 0 0 0
  1244. 15 15 0
  1245. SHAR_EOF
  1246. if test 29 -ne "`wc -c gray.col`"
  1247. then
  1248. echo shar: error transmitting gray.col '(should have been 29 characters)'
  1249. fi
  1250. cat << \SHAR_EOF > green.col
  1251. 0 2 0
  1252. 0 13 0
  1253. 0 0 6
  1254. 11 11 11
  1255. SHAR_EOF
  1256. if test 28 -ne "`wc -c green.col`"
  1257. then
  1258. echo shar: error transmitting green.col '(should have been 28 characters)'
  1259. fi
  1260. cat << \SHAR_EOF > lace.col
  1261. 5 5 5
  1262. 0 0 0
  1263. 0 2 7
  1264. 8 8 0
  1265. SHAR_EOF
  1266. if test 24 -ne "`wc -c lace.col`"
  1267. then
  1268. echo shar: error transmitting lace.col '(should have been 24 characters)'
  1269. fi
  1270. cat << \SHAR_EOF > modem.col
  1271. 0 0 0
  1272. 10 10 10
  1273. 12 12 12
  1274. 12 0 0
  1275. SHAR_EOF
  1276. if test 31 -ne "`wc -c modem.col`"
  1277. then
  1278. echo shar: error transmitting modem.col '(should have been 31 characters)'
  1279. fi
  1280. cat << \SHAR_EOF > pastel.col
  1281. 6 0 10
  1282. 15 14 7
  1283. 4 4 7
  1284. 13 9 7
  1285. SHAR_EOF
  1286. if test 28 -ne "`wc -c pastel.col`"
  1287. then
  1288. echo shar: error transmitting pastel.col '(should have been 28 characters)'
  1289. fi
  1290. cat << \SHAR_EOF > red.col
  1291. 6 0 0
  1292. 13 9 0
  1293. 0 2 4
  1294. 15 15 15
  1295. SHAR_EOF
  1296. if test 28 -ne "`wc -c red.col`"
  1297. then
  1298. echo shar: error transmitting red.col '(should have been 28 characters)'
  1299. fi
  1300. cat << \SHAR_EOF > royal.col
  1301. 2 0 4
  1302. 15 14 0
  1303. 0 0 8
  1304. 15 15 15
  1305. SHAR_EOF
  1306. if test 29 -ne "`wc -c royal.col`"
  1307. then
  1308. echo shar: error transmitting royal.col '(should have been 29 characters)'
  1309. fi
  1310. cat << \SHAR_EOF > silver.col
  1311. 6 8 9
  1312. 0 0 0
  1313. 0 0 8
  1314. 15 15 15
  1315. SHAR_EOF
  1316. if test 27 -ne "`wc -c silver.col`"
  1317. then
  1318. echo shar: error transmitting silver.col '(should have been 27 characters)'
  1319. fi
  1320. cat << \SHAR_EOF > silver2.col
  1321. 6 8 9
  1322. 15 15 15
  1323. 0 0 11
  1324. 0 0 0
  1325. SHAR_EOF
  1326. if test 28 -ne "`wc -c silver2.col`"
  1327. then
  1328. echo shar: error transmitting silver2.col '(should have been 28 characters)'
  1329. fi
  1330. cat << \SHAR_EOF > wb.col
  1331. 0 0 7
  1332. 15 15 15
  1333. 0 0 2
  1334. 15 8 0
  1335. SHAR_EOF
  1336. if test 28 -ne "`wc -c wb.col`"
  1337. then
  1338. echo shar: error transmitting wb.col '(should have been 28 characters)'
  1339. fi
  1340. #    End of shell archive
  1341. exit 0
  1342.  
  1343.